import request from '@/utils/request';

/**
 * 要素字段信息分页列表查询
 * @param {*} reqWrapperData 
 * @returns 
 */
export function pageList(reqWrapperData) {
    const {query, data} = reqWrapperData
  return request({
    url: '/datastandard/business/field/list',
    method: 'post',
    headers: {'X-HTTP-Method-Override': 'GET'},
    params: {
        page:query.page,
        pageSize:query.pageSize
    },
    data:{
        // id:data.id,
        fieldName:data.fieldName,
        // fieldAlias:data.fieldAlias,
        // fieldType:data.fieldType,
        // fieldLength:data.fieldLength,
        // fieldPrecision:data.fieldPrecision,
        // isNullable:data.isNullable,
        // isUnique:data.isUnique,
        // isStandard:data.isStandard,
        // canEnum:data.canEnum,
        // fieldOrder:data.fieldOrder,
        // fieldDesc:data.fieldDesc,
        // featureVersionId:data.featureVersionId,
        // versionName:data.versionName,
        versionCName:data.versionCName,
        // versionSerial:data.versionSerial,
        // featureId:data.featureId,
        // featureName:data.featureName,
        featureCName:data.featureCName,
        // isGeometry:data.isGeometry,
        // geometryType:data.geometryType,
        businessType:data.businessType,
        // updateMethod:data.updateMethod,
        // updateRate:data.updateRate,
    }
  });
}

/**
 * 添加一个新的要素字段信息
 * @param {*} reqWrapperData 
 * @returns 
 */
export function addOne(reqWrapperData) {
  const {data} = reqWrapperData
  return request({
    url: '/datastandard/fields/add',
    method: 'post',
    data:{
        id: data.id,
        fieldName: data.fieldName,
        fieldAlias: data.fieldAlias,
        fieldType: data.fieldType,
        fieldLength: data.fieldLength,
        fieldPrecision: data.fieldPrecision,
        isNullable: data.isNullable,
        isUnique: data.isUnique,
        standardDocId:data.standardDocId,
        isStandard: data.isStandard,
        canEnum:data.canEnum,
        fieldOrder: data.fieldOrder,
        fieldDesc: data.fieldDesc,
        featureVersionId: data.featureVersionId
    }
  });
}


/**
 * 修改一个新的要素字段信息
 * @param {*} reqWrapperData 
 * @returns 
 */
 export function updateOne(reqWrapperData) {
  const {data} = reqWrapperData
  return request({
    url: '/datastandard/fields/update',
    method: 'put',
    data:{
        id: data.id,
        fieldName: data.fieldName,
        fieldAlias: data.fieldAlias,
        fieldType: data.fieldType,
        fieldLength: data.fieldLength,
        fieldPrecision: data.fieldPrecision,
        isNullable: data.isNullable,
        isUnique: data.isUnique,
        standardDocId:data.standardDocId,
        isStandard: data.isStandard,
        canEnum:data.canEnum,
        fieldOrder: data.fieldOrder,
        fieldDesc: data.fieldDesc,
        featureVersionId: data.featureVersionId
    }
  });
}


/**
 * 修改一个要素字段信息
 * @param {*} reqWrapperData 
 * @returns 
 */
export function deleteOne(reqWrapperData) {
  const {query} = reqWrapperData
  return request({
    url: '/datastandard/fields/delete',
    method: 'delete',
    params:{
      id:query.id
    }
  });
}

/**
 * 批量导入字段数据
 * @param {*} reqFormData 
 * @returns 
 */
export function importBatchData(reqFormData){
  return request({
    url:'/datastandard/fields/importBatchData',
    method:'post',
    data:reqFormData
  })
}